import { Body, Controller, Get, Post, Res, HttpStatus, UploadedFile, UseInterceptors, HttpException, Query, Request } from '@nestjs/common';

import { UserFuncController } from '../user/userFunc.controller';

import {
  apibefore
} from '../../router'
import { InternetCelebrityGroupCheckService } from './internetCelebrityGroupCheck.service';
import { UserService } from '../user/user.service';
import { ValidUniqueLoginInterceptor } from 'src/interceptor/validUniqueLogin';
import utils from 'src/common/utils';
@Controller(apibefore('/internetCelebrityGroupCheckBackground'))
export class InternetCelebrityGroupCheckBackgroundController extends UserFuncController {
  constructor(private readonly service: InternetCelebrityGroupCheckService,
    private readonly userService: UserService
  ) {
    super(userService)
  }
   /**
   * 查询所有网红
   * @param params 
   * @param req 
   * @returns 
   */
   @Get('/findAll_Checking')
   @UseInterceptors(ValidUniqueLoginInterceptor)
   async findAll_Checking(@Query() params: {pageSize:number, pageIndex: number, keyword: string, ic_group_id?: number, platform_checking?: number, nav_video_id?: any}, @Request() req) {
     //查询用户的wx_user
     let findUser = await this.findWxUser(req.headers.token)
     if(findUser.error){
       return new HttpException(findUser.error, HttpStatus.INTERNAL_SERVER_ERROR)
     }
     const { skip, take } = utils.getLimit(params.pageSize, params.pageIndex)
     return await this.service.findAll_Checking(skip, take, params.platform_checking, params.nav_video_id)
   }

  @Post('/ic_accept')
  @UseInterceptors(ValidUniqueLoginInterceptor)
  async ic_Accept(@Body() data, @Request() req) {
    //查询用户的wx_user
    let findUser = await this.findWxUser(req.headers.token)
    if(findUser.error){
      return new HttpException(findUser.error, HttpStatus.INTERNAL_SERVER_ERROR)
    }
    let err = await this.service.ic_Accept(data.ic_group)
    if(err){
      return new HttpException(err, HttpStatus.INTERNAL_SERVER_ERROR)
    }else{
      return true
    }
  }

  @Post('/ic_reject')
  @UseInterceptors(ValidUniqueLoginInterceptor)
  async ic_Reject(@Body() data, @Request() req) {
    //查询用户的wx_user
    let findUser = await this.findWxUser(req.headers.token)
    if(findUser.error){
      return new HttpException(findUser.error, HttpStatus.INTERNAL_SERVER_ERROR)
    }
    let err = await this.service.ic_Reject(data.ic_group, data.reason_id)
    if(err){
      return new HttpException(err, HttpStatus.INTERNAL_SERVER_ERROR)
    }else{
      return true
    }
  }
}
